﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Devonline.Core;

namespace Devonline.Identity
{
    /// <summary>
    /// 组织机构, 字符串类型的默认实现
    /// </summary>
    [Table("group"), DisplayName("组织机构")]
    public class Group : Group<string>
    {
        /// <summary>
        /// 上级组织
        /// </summary>
        public virtual Group Parent { get; set; }
        /// <summary>
        /// 组织级别
        /// </summary>
        public virtual Level Level { get; set; }
    }

    /// <summary>
    /// 组织
    /// </summary>
    [Table("group"), DisplayName("组织机构")]
    public class Group<TKey> : Identity<TKey> where TKey : IConvertible
    {
        /// <summary>
        /// 上级组织
        /// </summary>
        [Column("parent_id"), DisplayName("上级组织"), MaxLength(36), Excel]
        public virtual TKey ParentId { get; set; }
        /// <summary>
        /// 组织级别
        /// </summary>
        [Column("level_id"), DisplayName("组织级别"), MaxLength(36), Excel]
        public virtual TKey LevelId { get; set; }
    }
}